Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement WithExactWord to allow stricter matches #107

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ntietz
Copy link

@ntietz ntietz commented Dec 19, 2024

Summary

This is a fix for #38 to filter only exact words.

I chose to implement it by having an alternate implementation only for the profanities list, where the rest is untouched so false positives and false negatives will remain working as expected; it seems right to me that a false negative should not change from exact word matches.

I have one test in here. I could see a use for more, but comments/feedback in that area would be appreciated so I can calibrate what sort of test coverage you're aiming for.

Checklist

  • Tested and/or added tests to validate that the changes work as intended, if applicable.
  • Updated documentation in README.md, if applicable.

goaway_test.go Outdated
Comment on lines 597 to 600
{
name: "With Custom Dictionary",
profanityDetector: NewProfanityDetector().WithCustomDictionary(DefaultProfanities, DefaultFalsePositives, DefaultFalseNegatives),
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
name: "With Custom Dictionary",
profanityDetector: NewProfanityDetector().WithCustomDictionary(DefaultProfanities, DefaultFalsePositives, DefaultFalseNegatives),
},
{
name: "With Custom Dictionary",
profanityDetector: NewProfanityDetector().WithCustomDictionary(DefaultProfanities, DefaultFalsePositives, DefaultFalseNegatives),
},

Was this a typo? It's a duplicate of the scenario above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I meant to have it include coverage of the new code by setting it to use exact words for one of them. pushed that fix in bf6efc8

goaway_test.go Outdated
Comment on lines 552 to 556
accept_sentences := []string{
"I'm an analyst",
}
reject_sentences := []string{"Go away, ass."}
tests := []struct {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
accept_sentences := []string{
"I'm an analyst",
}
reject_sentences := []string{"Go away, ass."}
tests := []struct {
accept_sentences := []string{
"I'm an analyst",
}
reject_sentences := []string{"Go away, ass."}
tests := []struct {

Go uses camelCase instead of snake_case - could you make the changes to the other parts of your code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in bf6efc8, thank you! the perils of switching between languages and getting my styles mixed up 😅

Copy link
Author

@ntietz ntietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the feedback @TwiN ! I've updated the PR with it. sorry it took a while—shortly after the feedback I went on holiday, but I should be able to have more timely iteration now if this needs any further work.

goaway_test.go Outdated
Comment on lines 597 to 600
{
name: "With Custom Dictionary",
profanityDetector: NewProfanityDetector().WithCustomDictionary(DefaultProfanities, DefaultFalsePositives, DefaultFalseNegatives),
},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I meant to have it include coverage of the new code by setting it to use exact words for one of them. pushed that fix in bf6efc8

goaway_test.go Outdated
Comment on lines 552 to 556
accept_sentences := []string{
"I'm an analyst",
}
reject_sentences := []string{"Go away, ass."}
tests := []struct {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in bf6efc8, thank you! the perils of switching between languages and getting my styles mixed up 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants